package com.dong.config;

import com.dong.dao.BookDao;
import com.dong.filter.MyTpyeFilter;
import com.dong.service.BookService;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

/**
 * excludeFilters: 扫描中进行排除
 * includeFilters:扫描的时候只包含   需要禁用默认规则 useDefaultFilters = false
 *              {@link FilterType.ANNOTATION}: 注解类型
 *              {@link FilterType.ASSIGNABLE_TYPE}: 按照给定类型
 *
 *              两个包含过滤器是 "或" 的关系
 *              两个排除过滤器是 "与" 的关系
 *
 *               {@link FilterType.REGEX} :使用正则
 *               {@link FilterType.CUSTOM} :  实现 TpyeFilter   这个判断后不需要有注解也能进入容器
 *               {@link FilterType.ASSIGNABLE_TYPE}:指定类型--->    加载该类及子类
 *
 */
@Configuration
@ComponentScans(value = {
        @ComponentScan(value="com.dong.dao",includeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION,value = Controller.class),
                @ComponentScan.Filter(type = FilterType.CUSTOM,classes ={MyTpyeFilter.class}),
                @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {BookDao.class})
        },useDefaultFilters = false),
        @ComponentScan(value="com.dong.service",excludeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION,classes =Repository.class),
                @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {BookService.class})
        })
})
public class T012IocConfig {
}
